<template>
  <div class="path">
    <div class="veicle">
      <span
        :class="!isCar ? 'iconfont active' : 'iconfont'"
        @click="changeVeicle(false)"
        >&#xe606;</span
      >
      <span
        :class="isCar ? 'iconfont active' : 'iconfont'"
        @click="changeVeicle(true)"
        >&#xe603;</span
      >
      <label class="iconfont cancel" @click="cancel">&#xe626;</label>
    </div>
    <div class="pan">
      <div class="left">
        <span class="iconfont icon" @click="transferPosition">&#xe61c;</span>
      </div>
      <div class="center">
        <p class="iptstart">
          <input
            type="text"
            :placeholder="transPosition ? '请输入终点' : '请输入起点'"
          />
        </p>
        <p class="iptcenter" v-for="(item, index) in byPosList" :key="index">
          <input
            type="text"
            placeholder="请输入途经点"
            v-model="byPosList[index]"
          />
        </p>
        <p class="iptend">
          <input
            type="text"
            :placeholder="transPosition ? '请输入起点' : '请输入终点'"
          />
        </p>
      </div>
      <div class="right">
        <span class="iconfont icon" @click="addStop">&#xe646;</span>
        <span class="iconfont icon" @click="deleteStop">&#xe65d;</span>
      </div>
    </div>
    <div class="go">
      <button id="btngo">出发</button>
    </div>
  </div>
</template>
<script>
export default {
  name: "pathl",
  data() {
    return {
      isCar: false, // 切换出行方式
      transPosition: false, // 切换起点和终点
      startPos: "",
      byPosList: [],
      endPos: ""
    };
  },
  methods: {
    //   改变出行方式
    changeVeicle: function(value) {
      this.isCar = value;
    },
    //  改变起点和终点
    transferPosition: function() {
      this.transPosition = !this.transPosition;
    },
    // 添加停靠点
    addStop: function() {
      this.byPosList.push("");
    },
    // 删除停靠点
    deleteStop: function() {
      this.byPosList.pop();
    },
    // 返回原始界面
    cancel: function(){
        this.$emit("getSearch");
    }
  }
};
</script>
<style lang="scss" scoped>
.path {
  position: absolute;
  left: 20px;
  top: 20px;
  padding-top: 10px;
  z-index: 100;
  width: 360px;
  min-height: 215;
  background: #3d93fd;
  box-shadow: 0 2px 2px rgba(0, 0, 0, 0.15);
  border-radius: 3px;
  text-align: center;
  box-sizing: border-box;
  .icon {
    color: #fff;
    display: block;
    opacity: 0.8;
    font-size: 17px;
    line-height: 25px;
    cursor: pointer;
    &:hover {
      opacity: 1;
    }
  }
  .cancel{
      position: absolute;
      right: 10px;
      top: 0;
      color: #fff;
      cursor: pointer;
      &:hover{
          opacity: .8;
      }
  }
  .veicle {
      position: relative;
    span {
      margin: 20px;
      color: #fff;
      font-size: 20px;
      cursor: pointer;
      opacity: 0.5;
    }
    .active {
      opacity: 1;
    }
  }
  .cancel {
  }
  .pan {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    .left {
      width: 50px;
    }
    .center {
      .iptstart,
      .iptcenter,
      .iptend {
        width: 260px;
        color: #acd7ff;
        margin-top: 5px;
      }
      input {
        width: 100%;
        height: 34px;
        line-height: 32px;
        border: none;
        background: transparent;
        text-indent: 5px;
        color: #e1f1ff;
        padding: 0;
        text-overflow: ellipsis;
        white-space: nowrap;
        background-color: #3587eb;
      }
      .fade-enter-active,
      .fade-leave-active {
        transition: all 0.5s;
      }
      .fade-enter,
      .fade-leave-to {
        opacity: 0;
      }
    }
    .right {
      width: 50px;
    }
  }
  .go {
    width: 310px;
    text-align: right;
    margin-top: 15px;
    padding-bottom: 15px;
    #btngo {
      display: inline-block;
      cursor: pointer;
      padding: 0 25px;
      height: 32px;
      line-height: 32px;
      background-color: #559ffb;
      border: none;
      border-radius: 2px;
      color: #fff;
      font-size: 14px;
      text-decoration: none;
      box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.21);
      -webkit-box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.21);
      -moz-box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.21);
    }
  }
}
</style>
